package NC;

public class NC29 {
    public boolean searchMatrix(int[][] matrix, int target) {
        // write code here

        int i = 0, j = matrix[0].length - 1;
        while (i < matrix.length && j >= 0) {
            if (matrix[i][j] == target) {
                return true;
            } else if (matrix[i][j] < target) {
                i++; //去掉这一行
            } else {
                j--;  //去掉这一列
            }
        }
        return false;
    }
}
